// 运行时配置
import { StyleProvider, legacyLogicalPropertiesTransformer } from '@ant-design/cssinjs'
import { App, ConfigProvider } from 'antd'
import zh_CN from 'antd/es/locale/zh_CN'
import React from 'react'

// 全局初始化数据配置，用于 Layout 用户信息和权限初始化
// 更多信息见文档：https://umijs.org/docs/api/runtime-config#getinitialstate
export async function getInitialState(): Promise<{ name: string }> {
  return { name: '@umijs/max' }
}

export function rootContainer(container: React.ReactElement) {
  return (
    <StyleProvider hashPriority="high" transformers={[legacyLogicalPropertiesTransformer]}>
      <ConfigProvider locale={zh_CN}>
        <App>{container}</App>
      </ConfigProvider>
    </StyleProvider>
  )
}

export const layout = () => {
  return {
    menu: {
      locale: false
    },
    pure: true
  }
}
